package com.stms.utils;

public class LogisticsPriceUtil {
    /**
     * standardWeight：标准重量、weightUnitCost：重量单价
     * distanceUnitCost：距离单价、continuedWeight：续重价格、value：货物价值、distance：距离
     */

    /**
     * 总邮费计算
     * weight（单位：kg）、distance（单位：km）
     */
    public static Double cost( Integer standardWeight,Double weightUnitCost,Double distanceUnitCost,Double continuedWeight,Double weight,Double value,Double distance){
        if(weight <= standardWeight){
            if(value<=100){
                return Math.ceil(weight*weightUnitCost + distance*distanceUnitCost);
            }else{
                return Math.ceil(weight*weightUnitCost + distance*distanceUnitCost + value/10);
            }
        }else{
            if(value<=100){
                return Math.ceil(standardWeight*weightUnitCost
                        + (weight-standardWeight)*continuedWeight
                        + distance*distanceUnitCost);
            }else {
                return Math.ceil(standardWeight * weightUnitCost
                        + (weight - standardWeight) * continuedWeight
                        + distance * distanceUnitCost
                        + value / 10);
            }
        }
    }
}
